import {generate} from '@/services/dashboard/workplace'

export default {
  namespaced: true,
  state: {
    current: 0,
    success: false,
    spinning: false,
    generate: {
      name: null,
      path: null,
      tableName: null,
      query: null,
      tableHead: null
    },
  },
  actions: {
    async generateCode({commit, state}) {
      await generate({...state.generate}).then((obj) => {
        let {success} = obj.data
        commit('setState', {name: 'success', value: success})
      })
      commit('setState', {name: 'spinning', value: false})
      commit('setState', {name: 'current', value: state.current + 1})
    }
  }
}